package fei.zhou.lambdalearn.demo5;

import java.util.function.Predicate;

/**
 * 描述该类- JPA
 *
 * @author zhoufei
 * @class: Toshow
 * @date 2020/12/22 20:49
 * @Verson 1.0 -2020/12/22 20:49
 * @see
 */
public class Demo2 {
    
    public static void main(String[] args) {
        boolean b1 = checkString2("A", (String s) -> {
            return s.equals("A");
        }, (String s) -> {
            return s.equals("B");
        });
        
        System.out.println("b1：" + b1);
        boolean b2 = checkString3("A", (String s) -> {
            return s.equals("A");
        }, (String s) -> {
            return s.equals("B");
        });
        System.out.println("b2：" + b2);
    }
    
    // 逻辑与运算
    private static boolean checkString2(String s, Predicate<String> pre1, Predicate<String> pre2) {
        return pre1.and(pre2).test(s);
    }
    // 逻辑或运算
    private static boolean checkString3(String s, Predicate<String> pre1, Predicate<String> pre2) {
        return pre1.or(pre2).test(s);
    }
}